
#pragma once

#include <linux/types.h>

/**
 * crc32_be() - Compute most-significant-bit-first IEEE CRC-32
 * @crc: Initial CRC value.  ~0 (recommended) or 0 for a new CRC computation, or
 *	 the previous CRC value if computing incrementally.
 * @p: Pointer to the data buffer
 * @len: Length of data in bytes
 *
 * crc32_be() is the same as crc32_le() except that crc32_be() computes the
 * *most-significant-bit-first* variant of the CRC.  I.e., within each byte, the
 * most significant bit is processed first (treated as highest order polynomial
 * coefficient).  The same bit order is also used for the CRC value itself:
 *
 * - Polynomial: x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 +
 *		 x^7 + x^5 + x^4 + x^2 + x^1 + x^0
 * - Bit order: Most-significant-bit-first
 * - Polynomial in integer form: 0x04c11db7
 *
 * Context: Any context
 * Return: The new CRC value
 */
u32 crc32_be(u32 crc, const void *p, size_t len);

/**
 * crc32_le() - Compute least-significant-bit-first IEEE CRC-32
 * @crc: Initial CRC value.  ~0 (recommended) or 0 for a new CRC computation, or
 *	 the previous CRC value if computing incrementally.
 * @p: Pointer to the data buffer
 * @len: Length of data in bytes
 *
 * crc32_le() computes the *least-significant-bit-first* variant of the CRC.
 * I.e., within each byte, the least significant bit is processed first (treated
 * as highest order polynomial coefficient).  The same bit order is also used
 * for the CRC value itself:
 *
 * - Polynomial: x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 +
 *		 x^7 + x^5 + x^4 + x^2 + x^1 + x^0
 * - Bit order: Least-significant-bit-first
 * - Polynomial in integer form: 0xedb88320 (bit-reversed of 0x04c11db7)
 *
 * Context: Any context
 * Return: The new CRC value
 */
u32 crc32_le(u32 crc, const void *p, size_t len);

